<template>
  <aside>
    <div :class="{'tabitem':true,active:index==i}" v-for="(item,i) in type" :key="i" @click="cut(i,item.type)">
      {{item.type}}
    </div>
  </aside>
</template>

<script>
import { getType } from "../../api/classify";
export default {
  data() {
    return {
      type: [],
      index:0
    };
  },
  mounted() {
    getType().then((res) => {
      this.type = res.data;
      this.cut(this.index,this.type[0].type)
    });
    
  },
  methods:{
    cut(i,type){
      this.index=i
      this.$emit('tab',type)
    }
  }
};
</script>

<style scoped>
aside {
  height: 100%;
  overflow: auto;
  width: 1.68rem;
  background-color: #f2f4f8;
}
.tabitem{
  margin-bottom: 0.2rem;
  height: 0.76rem;
  line-height: 0.76rem;
  font-size: 0.28rem;
  text-align: center;
}
.active{
  background-color: #ffffff;
  font-weight: bold;
  position: relative;
}
.active::after{
  content: '';
  display: inline-block;
  position: absolute;
  left: 0;
  top: 0;
  width: 0.08rem;
  height: 100%;
  background-color: #33b17b;
}
</style>
